package com.aca.market.common;

import com.aca.market.service.IShiroFilterService;
import org.springframework.beans.BeansException;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order
public class FilterListener implements ApplicationRunner, ApplicationContextAware {

    private static ApplicationContext context;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        IShiroFilterService shiroFilterService = (IShiroFilterService) context.getBean("shiroFilterService");
        shiroFilterService.reloadFilterChains();
    }
}
